/**
 * @FileDescription 公共api
 * @Author 祝小文
 * @CreateDate 2022-10-11 22:01
 */
import { chemical_server as request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(response: ResultType) {
  if (response.result.resultCode == '000000') {
    return response.data
  }
  throw new Error()
}

//全文搜索-如果key不为空,忽略菜单值全局搜索
export function querySearchInfo(params?: any) {
  return request.get(`/search-info/querySearchInfo`, { params }).then((res) => adapter(res as any))
}

//根据id查询字典代码表
export function queryZdZdmcInfo(params?: any) {
  return request.get(`/zd-zdmc/queryZdZdmcInfo`, { params }).then((res) => adapter(res as any))
}

//新增或修改位置信息表
export function insertOrUpdate(params?: any) {
  return request.post(`/wzxxb/insertOrUpdate`, params).then((res) => adapter(res as any))
}

//查询模型设置数据
export function queryMxdzInfo(params?: any) {
  return request.get(`/mxdz/queryMxdzInfo`, { params }).then((res) => adapter(res as any))
}

//保存模型设置数据
export function updateMxdzInfo(params?: any) {
  return request.post(`/mxdz/updateMxdzInfo`, params).then((res) => adapter(res as any))
}

//根据企业id查询全量地图要素
export function queryWzxxByQyIdAndBzLx(params?: any) {
  return request
    .get(`/wzxxb-view/queryWzxxByQyIdAndBzLx`, { params })
    .then((res) => adapter(res as any))
}
